package com.egov.wrdmp.reporting.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.egov.wrdmp.reporting.dao.ReportDAO;
import com.egov.wrdmp.reporting.model.Report;

@Repository
public class ReportDAOImpl implements ReportDAO{
	@Autowired
    private SessionFactory sessionFactory;
	
    public void addReport(Report report) {
        sessionFactory.getCurrentSession().save(report);
    }
	
    public List<Report> listReport() {
			
        return sessionFactory.getCurrentSession().createQuery("from Report").list();
    }
	
    public void removeReport(Integer id) {
    	Report report = (Report) sessionFactory.getCurrentSession().load(
    			Report.class, id);
        if (null != report) {
            sessionFactory.getCurrentSession().delete(report);
        }
 
    }
}
